home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 June: Reference Library / Dev.CD Jun 95 / Dev.CD Jun 95.toast / What's New? / Sample Code / QuickTime Sample Code / DTS QT Utilities.Apr-95 / Projects & Test Apps / QT Internals / Mac Framework / MacApplication.c < prev    next >
Encoding:
Text File  |  1995-04-16  |  3.9 KB  |  166 lines  |  [TEXT/MPCC]

  1. /*
  2.     File:        MacApplication.c
  3.  
  4.     Contains:    Functions that could be overridden in a specific application.
  5.  
  6.     Written by:    DTS
  7.  
  8.     Copyright:    © 1994-1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.        <1>         12/21/94    khs        first file
  13.        
  14. */
  15.  
  16.  
  17. // INCLUDES
  18. #include "MacApplication.h"
  19. #include "MacFramework.h"
  20. #include "AppConfiguration.h"
  21. #include "DTSQTUtilities.h"
  22.  
  23. #include "QTInternals.h"
  24.  
  25. // GLOBALS
  26. long gMaxMilliSecToUse = kMaxMilliSecToUse;        
  27.  
  28.  
  29. // ______________________________________________________________________
  30. // FUNCTIONS
  31. // ______________________________________________________________________
  32. void DoIdle(WindowRef theWindow)
  33. {
  34.     GrafPtr                 aSavedPort;
  35.     WindowObject         aWindowObject;
  36.     MovieController     mc = NULL;
  37.     
  38.     GetPort(&aSavedPort);
  39.     SetPort(theWindow);
  40.     
  41.     if( ( aWindowObject = (WindowObject)GetWRefCon(theWindow) ) != NULL)
  42.     {
  43.         if( (IsWindowObjectOurs(aWindowObject)) &&  ((mc = (**aWindowObject).controller) != NULL))
  44.             MoviesTask(MCGetMovie(mc), gMaxMilliSecToUse);    
  45.     }
  46.  
  47. // INSERT ANY IDLE BASED FUNCTIONALITY HERE
  48.  
  49.     SetPort(aSavedPort);
  50. }
  51.  
  52.  
  53. // ______________________________________________________________________
  54. void DoUpdateWindow(WindowRef theWindow, Rect *theRefrehArea)
  55. {
  56.     GrafPtr aSavedPort;
  57.     
  58.     GetPort(&aSavedPort);
  59.     SetPort(theWindow);
  60.     
  61.     BeginUpdate(theWindow);
  62.  
  63. // INSERT WINDOW SPECIFIC DRAWING FUNCTIONALITY HERE
  64.  
  65.     EndUpdate(theWindow);
  66.     SetPort(aSavedPort);
  67. }
  68.  
  69.  
  70. // ______________________________________________________________________
  71. void HandleContentClick(WindowRef theWindow, EventRecord *theEvent)
  72. {
  73.     GrafPtr aSavedPort;
  74.     
  75.     GetPort(&aSavedPort);
  76.     SetPort(theWindow);
  77.  
  78. // INSERT APPLICATION SPECIFIC CONTENT CLICKING FUNCTIONALITY HERE
  79.  
  80.     SetPort(aSavedPort);
  81. }
  82.  
  83.  
  84. // ______________________________________________________________________
  85. WindowRef CreateMovieWindow(Rect *theRect, Str255 theTitle)
  86. {
  87.     WindowRef aWindow;
  88.  
  89. // MODIFY IF NEEDED THE WAY TO CREATE NEW WINDOWS    
  90.     aWindow = NewCWindow(NULL, theRect, theTitle, false, noGrowDocProc, (WindowPtr) - 1L, true, 0);
  91.     
  92.     return aWindow;
  93. }
  94.  
  95.  
  96. // ______________________________________________________________________
  97. void HandleApplicationMenu(short theMenuID, short theMenuItem)
  98. {
  99.     MovieController mc = NULL;
  100.     
  101.     mc = GetMCFromFrontWindow();
  102.     if (mc == NULL) return;                            // we didn't have any movie windows frontmost
  103.     
  104.     //  HANDLE ANY ADDITIONAL MENU ENTRIES HERE
  105.     switch(theMenuID)
  106.     {
  107.         case mTesting:
  108.             switch(theMenuItem)
  109.             {
  110.                 case iTrackInfo:
  111.                 {
  112.                     ShowMovieTrackInfo(MCGetMovie(mc));
  113.                     break;
  114.                 }
  115.                 case iVideoInfo:
  116.                     ShowMovieVideoInfo(MCGetMovie(mc));
  117.                     break;
  118.                 
  119.                 case iSoundInfo:
  120.                     ShowMovieSoundInfo(MCGetMovie(mc));
  121.                     break;
  122.             }
  123.             break;
  124.     }
  125. }
  126.  
  127.  
  128. // ______________________________________________________________________
  129. void    AdjustApplicationMenus(void)
  130. {
  131.     WindowRef             aWindow = NULL;
  132.     MovieController     mc = NULL;
  133.     
  134.     mc = GetMCFromFrontWindow();
  135.     if(mc != NULL)                                // we do have windows with movie controllers = movie windows
  136.     {
  137.         EnableItem(GetMHandle(mTesting), iTrackInfo);
  138.         EnableItem(GetMHandle(mTesting), iVideoInfo);
  139.         EnableItem(GetMHandle(mTesting), iSoundInfo);
  140.     }
  141.     else
  142.     {
  143.         DisableItem(GetMHandle(mTesting), iTrackInfo);
  144.         DisableItem(GetMHandle(mTesting), iVideoInfo);
  145.         DisableItem(GetMHandle(mTesting), iSoundInfo);
  146.     }
  147. }
  148.  
  149.  
  150. // ______________________________________________________________________
  151. void AddControllerFunctionality(MovieController mc)
  152. {
  153.     long controllerFlags;
  154.     
  155. // Specify here the functionality you want to have added to the movie controller.
  156.  
  157. // CLUT Table use    
  158.     MCDoAction(mc, mcActionGetFlags, &controllerFlags);
  159.     MCDoAction(mc, mcActionSetFlags, (void *) (controllerFlags | mcFlagsUseWindowPalette));
  160.  
  161. // Enable keyboard event handling    
  162.     MCDoAction(mc, mcActionSetKeysEnabled, (void *) true);
  163.     
  164. // Enable Drag Support (assume we have System 7.5 for the time being)
  165.     MCDoAction(mc, mcActionSetDragEnabled, (void *) true);
  166. }